/*
 * The MIT License
 *
 * Copyright 2011 Edwin Bratini <edwin.bratini@gmail.com>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

/*
 * EliminacionRegistroDialog.java
 *
 * Created on Nov 9, 2011, 12:45:12 PM
 */
package org.salvador_dali.psychsys.ui;

import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import org.salvador_dali.psychsys.ui.EliminacionRegistroDialog.OPCION_ACCION_ELIMINACION;
import org.salvador_dali.psychsys.ui.EliminacionRegistroDialog.OPCION_ELIMINACION;

/**
 *
 * @author Edwin Bratini <edwin.bratini@gmail.com>
 */
public class EliminacionVariosRegistrosDialog extends javax.swing.JDialog {

    private OPCION_ELIMINACION opEliminacion;
    private OPCION_ACCION_ELIMINACION opAccion;

    /** Creates new form EliminacionRegistroDialog */
    public EliminacionVariosRegistrosDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        lblProgressBar.setVisible(false);
    }
    
    public EliminacionVariosRegistrosDialog(java.awt.Frame parent, boolean modal, String mensaje, String title) {
        this(parent, modal);
        lblMensajeEliminacion.setText(mensaje);
        setTitle(title);
    }

    public EliminacionVariosRegistrosDialog(java.awt.Frame parent, boolean modal, String mensaje, String title, ImageIcon iconoMensaje) {
        this(parent, modal, mensaje, title);
        lblIconoMensaje.setIcon(iconoMensaje);
    }

    public OPCION_ACCION_ELIMINACION getOpAccion() {
        return opAccion;
    }

    public OPCION_ELIMINACION getOpEliminacion() {
        return opEliminacion;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblMensajeEliminacion = new javax.swing.JLabel();
        chkCambiarStatus = new javax.swing.JCheckBox();
        lblIconoMensaje = new javax.swing.JLabel();
        btnSi = new javax.swing.JButton();
        lblProgressBar = new javax.swing.JLabel();
        btnNo = new javax.swing.JButton();
        lblEscMensaje = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Eliminar Varios Registros [Estudiantes]");
        setModal(true);
        setResizable(false);

        lblMensajeEliminacion.setText("<html>¿Seguro que desea eliminar<br />estos 2 registros?</html>");

        chkCambiarStatus.setSelected(true);
        chkCambiarStatus.setText("Solo cambiar status");

        lblIconoMensaje.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/images/delete_65x65.png"))); // NOI18N

        btnSi.setText("Si");
        btnSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSiActionPerformed(evt);
            }
        });

        lblProgressBar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/images/circle progress bar 20x20.png"))); // NOI18N

        btnNo.setText("No");
        btnNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNoActionPerformed(evt);
            }
        });

        lblEscMensaje.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/images/information 20x20.png"))); // NOI18N
        lblEscMensaje.setText("<html>ESC para<br> cancelar</html>");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblIconoMensaje)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(chkCambiarStatus)
                        .addGap(18, 18, 18)
                        .addComponent(lblProgressBar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSi, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnNo, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblMensajeEliminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
                        .addComponent(lblEscMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIconoMensaje)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblMensajeEliminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblEscMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(7, 7, 7)
                                .addComponent(chkCambiarStatus))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnNo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnSi, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE))
                            .addComponent(lblProgressBar))))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSiActionPerformed
// TODO add your handling code here:
    this.opEliminacion = OPCION_ELIMINACION.SI;
    if (chkCambiarStatus.isSelected()) {
        this.opAccion = OPCION_ACCION_ELIMINACION.CAMBIAR_STATUS;
    } else {
        this.opAccion = OPCION_ACCION_ELIMINACION.PERMENTE;
    }
    this.dispose();
}//GEN-LAST:event_btnSiActionPerformed

    private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
        // TODO add your handling code here:
        this.opEliminacion = OPCION_ELIMINACION.NO;
        this.dispose();
    }//GEN-LAST:event_btnNoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EliminacionVariosRegistrosDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EliminacionVariosRegistrosDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EliminacionVariosRegistrosDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EliminacionVariosRegistrosDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                EliminacionVariosRegistrosDialog dialog = new EliminacionVariosRegistrosDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    public JCheckBox getChkCambiarStatus() {
        return chkCambiarStatus;
    }

    public void setChkCambiarStatus(JCheckBox chkCambiarStatus) {
        this.chkCambiarStatus = chkCambiarStatus;
    }

    public JLabel getLblMensajeEliminacion() {
        return lblMensajeEliminacion;
    }

    public void setLblMensajeEliminacion(JLabel lblMensajeEliminacion) {
        this.lblMensajeEliminacion = lblMensajeEliminacion;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnNo;
    private javax.swing.JButton btnSi;
    private javax.swing.JCheckBox chkCambiarStatus;
    private javax.swing.JLabel lblEscMensaje;
    private javax.swing.JLabel lblIconoMensaje;
    private javax.swing.JLabel lblMensajeEliminacion;
    private javax.swing.JLabel lblProgressBar;
    // End of variables declaration//GEN-END:variables
}
